from functools import wraps
from flask import g,redirect,url_for,session

#装饰器
def login_required(func):
    #保留func的信息
    @wraps(func)
    def inner(*args,**kwargs):
        if "username" in session:
            return func(*args,**kwargs)
        else:
            return redirect(url_for("login"))
    return inner
